home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 933 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.5 KB

  1. From: Nico Josuttis <nico@bredex.de>
  2. Message-ID: <199604020924.LAA07380@bredex.bredex.de>
  3. X-Original-Date: Tue, 02 Apr 96 11:24:07 +0200
  4. Path: in2.uu.net!bounce-back
  5. Date: 02 Apr 96 13:32:05 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Organization: -
  8. Newsgroups: comp.std.c++
  9. X-Authentication-Warning: bredex.bredex.de: Host localhost didn't use HELO protocol
  10. Cc: nico@bredex.de
  11. Subject: reserve() and capacity()
  12. X-Mts: smtp
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMWEsdeEDnX0m9pzZAQG1ugGAkaFnOiPzXUutcWPoxx1i9X33KRm7a2SE
  15.     0TPrBgS8dYx23KDBq5iF7V+AWHNx76b6
  16.     =FQZn
  17.  
  18. Two "container" have reserve() and capacity():
  19.  string and vector.
  20. For both first a simple hint:
  21. The january draft says, that 
  22.     It is guaranteed that no
  23.     reallocation takes place during the  insertions  that  happen  after
  24.     reserve()  takes  place  till  the  time when the size of the vector/string
  25.  
  26.     reaches the size specified by reserve().
  27. First "reaching" the size should also guarantee that no reallocation takes
  28. place. I think "exceeds" would be the correct naming here.
  29.  
  30. But I have deeper questions:
  31. For vectors for every member function it is documented how it unvalidates
  32. iterators and references.
  33. Following that I would guess that
  34.  a) vector capacity in general can't shrink
  35.  b) iterators stay valid even if following elements get destroyed
  36. On the other hand the standard says that
  37.  a) no reallocation takes place during the  INSERTIONS ...
  38.  b) The reference returned by the non-const version is invalid after any
  39.     subsequent call to c_str(), data(), or any non-const member function
  40.     for the object. 
  41.     (only for string, the vector version is missing)
  42.  
  43. So my questions are:
  44.  - What is right for vector and string?
  45.  - How long stay iterators and references valid for both?
  46.  - May the capacity() shrink for both?
  47.  
  48. Thanks in advance
  49. --------
  50. Nico                             address: BREDEX GmbH
  51. email:   nico@bredex.de                   Nicolai Josuttis
  52.                                           Fallersleber-Tor-Wall 23
  53. phone:   +49 531 24330-0                  D-38100 Braunschweig
  54. fax:     +49 531 24330-99                 Germany
  55. --------
  56. ---
  57. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  58. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  59. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  60. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  61. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  62.